package com.feihao.demoDate;

import java.util.Comparator;

public class Student implements Comparator<Student> ,Comparable<Student>{
    private int age;
    private String name;

    public Student() {

    }

    public Student(int age, String name) {
        this.age = age;
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }


    @Override
    public int compare(Student o1, Student o2) {
        return o1.getAge() - o2.getAge();
    }

    @Override
    public Comparator<Student> reversed() {
        return null;
    }

    @Override
    public int compareTo(Student o) {
        return this.getAge() - o.getAge();
    }
}
